home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra / disp186b.zip / SPARADIS.ASM < prev    next >
Assembly Source File  |  1993-08-24  |  8KB  |  324 lines

  1. ;--------------------------------------------------------------------------
  2. ; This is file SPARADIS.ASM
  3. ;
  4. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  5. ; Copyright (C) 1992 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221
  6. ;    # Modified June 1993 by Nick van der Merwe , Department of Surveying
  7. ;                University of Cape Town , South Africa
  8. ;      changes made: SVGA support
  9. ;
  10. ; This file is distributed under the terms listed in the document
  11. ; "copying.dj", available from DJ Delorie at the address above.
  12. ; A copy of "copying.dj" should accompany this file; if not, a copy
  13. ; should be available from where this file was obtained.  This file
  14. ; may not be distributed without a verbatim copy of "copying.dj".
  15. ;
  16. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  17. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. ;--------------------------------------------------------------------------
  19.  
  20. ;include grdriver.inc?
  21. cseg    segment    byte public 'code'
  22.     assume    cs:cseg, ds:cseg, es:cseg, ss:nothing
  23.  
  24.     dw    offset init_routine
  25.     dw    offset paging_routine
  26.     dw    0    ; set to 1 if separate read & write windows or
  27.             ; only 64K of video RAM (ie: no paging)
  28.  
  29. def_tw    dw    80    ; filled in by go32 if GO32 env. var. is set
  30. def_th    dw    25
  31. def_gw    dw    640
  32. def_gh    dw    480
  33. def_nc     dw    16        ;graphics colors
  34.     dw    offset driver_init_routine
  35.     dw    offset text_mode_table
  36.     dw    offset graphics_mode_table
  37.  
  38. ;
  39. ; Biggest text and graphics sizes
  40. ;
  41.  
  42. Max_TW  equ    132
  43. Max_TH  equ    44
  44. Max_GWn equ    800        ; non interlaced!!!
  45. Max_GHn equ    600
  46. Max_GW  equ    1024        ; may be interlaced
  47. Max_GH  equ    768
  48.  
  49. ;--------------------------------------------------------------------------
  50. ; TABLE OF SUPPORTED TEXT MODES
  51. ;    - keep sorted by size
  52. ;    - end with an all 0 entry
  53. ;    - BIOS field = 0xff disables it
  54. ;    - fields:
  55. ;        width,  height, colors, BIOS#+  setup_procedure_index*256
  56. ;--------------------------------------------------------------------------
  57. text_mode_table        label word
  58.     dw    80,    25,    2,    007h +  00000h
  59.     dw    40,    25,    16,    001h +  00000h
  60.     dw    80,    25,    16,    003h +  00000h
  61.     dw    80,    30,    16,    012h +  00000h
  62.     dw    80,    34,    16,    041h +  00000h
  63.     ;dw    80,    60,    16,    052h +  00000h
  64.     dw    132,    25,    16,    055h +  00000h
  65.     dw    132,    28,    16,    047h +  00000h
  66.     dw    132,    44,    16,    021h +  00000h
  67.     dw    40,    25,    256,    056h +  00000h
  68.     dw    0,    0,    0,    000h +  00000h
  69.  
  70.  
  71. ;--------------------------------------------------------------------------
  72. ; TABLE OF SUPPORTED GRAPHICS MODES
  73. ;    - keep sorted first by colors then by size
  74. ;    - end with an all 0 entry
  75. ;    - BIOS field = 0xff disables it
  76. ;    - fields:
  77. ;        width,  height, colors, BIOS#+  setup_procedure_index*256
  78. ;--------------------------------------------------------------------------
  79. graphics_mode_table    label word
  80.     dw    320,    200,    16,    00dh +  00000h
  81.     dw    640,    200,    16,    00eh +  00000h
  82.     dw    640,    350,    16,    010h +  00000h
  83.     dw    640,    480,    16,    012h +  00000h
  84.     dw    800,    600,    16,    058h +  00000h
  85.     dw    1024,    768,    16,    05dh +  00000h
  86.     dw    320,    200,    256,    013h +  00000h
  87.     dw    640,    400,    256,    05eh +  00000h
  88.     dw    640,    480,    256,    05fh +  00000h
  89.     dw    800,    600,    256,    05ch +  00000h
  90.     dw    1024,    768,    256,    060h +  00000h
  91.     dw    0,    0,    0,    000h +  00000h
  92.  
  93.  
  94. ;--------------------------------------------------------------------------
  95. ; TABLE OF SPECIAL SETUP PROCEDURES
  96. ;  You may need such procedures for:
  97. ;     -- reloading fonts on standard EGA or VGA for
  98. ;     higher resolution text modes
  99. ;     -- enable HiColor mode of some Super VGAs
  100. ;     -- Handle the parameter passing conventions of the VESA BIOS
  101. ;     -- put VGA into 256 color plane mode ("MODE X")
  102. ;     -- etc...
  103. ;  There should be one entry in the table for every non-zero
  104. ;  'setup_procedure_index' in the text and graphics mode tables.
  105. ;  The first entry in the table belongs to index 100h, and so on.
  106. ;  The special setup procedure is invoked via a near call.
  107. ;
  108. ;  Entry: DI=address of the mode record from the text or graphics
  109. ;      table to set up.
  110. ;
  111. ;  Exit:  Adapter configured
  112. ;      BX=driver mode word as it should be returned by the mode set
  113. ;         routine. Typically it involves picking up the mode word
  114. ;         from the header and OR-ing in the appropriate bitplane mode
  115. ;         bitfield. (This is not needed for text modes)
  116. ;      AX, CX, DX, SI can be trashed, PRESERVE DI!!!!
  117. ;
  118. ;  NOTE: This runs in real mode, but don't mess with the segment registers.
  119. ;--------------------------------------------------------------------------
  120. special_setup_table    label word
  121.     dw    0    ; none here !!
  122.  
  123.  
  124. ;--------------------------------------------------------------------------
  125. ; DRIVER INIT ROUTINE
  126. ;  called once after the driver is loaded
  127. ;  may do one or more of the followings:
  128. ;    - check for proper board type
  129. ;    - check amount of RAM on board, and:
  130. ;    -- update word in header to reflect correct amount
  131. ;    -- disable modes in the tables for which there is not enough RAM
  132. ;    - check for special equipment (HiColor DAC, etc...)
  133. ;
  134. ;  Entry: nothing
  135. ;
  136. ;  Exit:  AX=status:
  137. ;       non-zero: OK,
  138. ;       0: something went wrong (e.g. wrong adapter, etc..)
  139. ;      BX,CX,DX may be trashed
  140. ;
  141. ;  NOTE: This runs in real mode, but don't mess with the segment registers.
  142. ;--------------------------------------------------------------------------
  143. driver_init_routine    proc    far
  144.     mov    ax,1
  145.     ret
  146. driver_init_routine    endp
  147.  
  148. ;--------------------------------------------------------------------------
  149. ; Entry: AX=mode selection
  150. ;        0=80x25 text
  151. ;        1=default text
  152. ;        2=text CX cols by DX rows
  153. ;        3=biggest text
  154. ;        4=320x200 graphics
  155. ;        5=default graphics
  156. ;        6=graphics CX width by DX height
  157. ;        7=biggest non-interlaced graphics
  158. ;        8=biggest graphics
  159. ;
  160. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  161. ;
  162. ; Exit:  CX=width (in pixels or characters)
  163. ;        DX=height
  164.  
  165. init_table    label    word
  166.     dw    offset init_0
  167.     dw    offset init_1
  168.     dw    offset init_2
  169.     dw    offset init_3
  170.     dw    offset init_4
  171.     dw    offset init_5
  172.     dw    offset init_6
  173.     dw    offset init_7
  174.     dw    offset init_8
  175.  
  176. init_routine    proc    far
  177.     cmp    ax,8
  178.     jbe    valid_req
  179.     ret
  180. valid_req:
  181.     shl    ax,1
  182.     mov    bx,ax
  183.     jmp    init_table[bx]
  184.  
  185. init_0: ; 80x25 text
  186.     mov    ax,3
  187.     int    10h
  188.     mov    cx,80
  189.     mov    dx,25
  190.     ret
  191.  
  192. init_1: ; default text
  193.     mov    cx,def_tw
  194.     mov    dx,def_th
  195.     jmp    init_2
  196.  
  197. init_2_table    label    word
  198.     dw    01h, 40, 25
  199.     dw    03h, 80, 25
  200. init_2_tend    label    word
  201.  
  202. init_2: ; CX*DX text
  203.     mov    si,offset init_2_table
  204. init_2a:
  205.     cmp    [si+2],cx
  206.     jb    init_2b
  207.     cmp    [si+4],dx
  208.     jb    init_2b
  209.     ; got a big enough one!
  210.     jmp    init_2c
  211. init_2b:
  212.     cmp    si,offset init_2_tend - 6
  213.     je    init_2c
  214.     add    si,6
  215.     jmp    init_2a
  216. init_2c:
  217.     mov    ax,[si]
  218.     push    si
  219.     int    10h
  220.     pop    si
  221.     mov    cx,[si+2]
  222.     mov    dx,[si+4]
  223.     ret
  224.  
  225. init_3: ; biggest text
  226.     mov    ax,[init_2_tend-6]
  227.     int    10h
  228.     mov    cx,[init_2_tend-4]
  229.     mov    dx,[init_2_tend-2]
  230.     ret
  231.  
  232. init_4: ; 320x200 graphics
  233.     mov    ax,13h
  234.     int    10h
  235.     mov    cx,320
  236.     mov    dx,200
  237.     ret
  238.  
  239. init_5: ; default graphics - should be 640x480 if supported
  240.     mov    cx,def_gw
  241.     mov    dx,def_gh
  242.     jmp    init_6
  243.  
  244. init_6_table    label    word
  245.     dw    13h, 320, 200
  246.     dw    5eh, 640, 400
  247.     dw    5fh, 640, 480
  248. init_6_tend    label    word
  249.  
  250. init_6: ; CX*DX graphics
  251.     mov    si,offset init_6_table
  252. init_6a:
  253.     cmp    [si+2],cx
  254.     jb    init_6b
  255.     cmp    [si+4],dx
  256.     jb    init_6b
  257.     ; got a big enough one!
  258.     jmp    init_6c
  259. init_6b:
  260.     cmp    si,offset init_6_tend - 6
  261.     je    init_6c
  262.     add    si,6
  263.     jmp    init_6a
  264. init_6c:
  265.     mov    ax,[si]
  266.     push    si
  267.     int    10h
  268.     pop    si
  269.     mov    cx,[si+2]
  270.     mov    dx,[si+4]
  271.     ret
  272.  
  273. init_7: ; biggest non-interlaced graphics
  274.     mov    ax,5fh
  275.     int    10h
  276.     mov    cx,640
  277.     mov    dx,480
  278.     ret
  279.  
  280. init_8: ; biggest graphics
  281.     mov    ax,5fh
  282.     int    10h
  283.     mov    cx,640
  284.     mov    dx,480
  285.     ret
  286.  
  287. init_routine    endp
  288.  
  289. ;--------------------------------------------------------------------------
  290. ; Entry: AH=read page
  291. ;        AL=write page
  292. ;
  293. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  294. ; This code must be relocatable and may not reference any data!
  295. ;
  296. ; Exit: VGA configured.
  297. ;       AX,BX,CX,DX,SI,DI may be trashed
  298. ;
  299. ; Derived from code from VGAKIT Version 3.4
  300. ;    Copyright 1988,89,90 John Bridges
  301.  
  302.     assume    ds:nothing, es:nothing
  303.  
  304. paging_routine    proc    far
  305.     mov    cx,ax
  306.     mov    dx,3ceh
  307.     mov    ax,50fh        ;turn off write protect on VGA registers
  308.     out    dx,ax
  309.     mov    ah,cl
  310.     shl    ah,1
  311.     shl    ah,1
  312.     shl    ah,1
  313.     shl    ah,1
  314.     mov    al,9
  315.     out    dx,ax
  316.  
  317.     ret
  318. paging_routine    endp
  319.  
  320. ;--------------------------------------------------------------------------
  321.  
  322. cseg    ends
  323.     end
  324.